package com.epmxx.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.epmxx.vo.RoomQuery;
import com.epmxx.vo.RoomVO;
import com.epmxx.domain.Hotel;
import com.epmxx.domain.Room;
import com.epmxx.service.RoomService;
import com.epmxx.mapper.RoomMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* 酒店业务接口实现类
*/
@Service
public class RoomServiceImpl extends ServiceImpl<RoomMapper, Room>
implements RoomService{

    @Autowired
    private RoomMapper roomMapper;

    /**
     * 分页查询
     *
     * @param query
     * @return
     */
    @Override
    public PageInfo<RoomVO> queryPage(RoomQuery query) {
        // 开启分页
        Page<RoomVO> data = PageHelper.startPage(query.getPage(), query.getLimit());
        this.roomMapper.selectList(query);
        return data.toPageInfo();
    }

    /**
     * 查询所有酒店，渲染酒店下拉框
     *
     * @return
     */
    @Override
    public List<Hotel> queryHotel() {
        return this.roomMapper.selectHotel();
    }

    /**
     * 新增酒店房间信息
     *
     * @param room
     */
    @Override
    public void add(Room room) {
        this.roomMapper.insert(room);
    }

    /**
     * 删除酒店房间信息
     *
     * @param id
     */
    @Override
    public void delete(Integer id) {
        this.roomMapper.deleteById(id);
    }

    /**
     * 修改酒店房间信息
     *
     * @param room
     */
    @Override
    public void update(Room room) {
        this.roomMapper.updateById(room);
    }

    /**
     * 批量删除
     *
     * @param id
     * @return
     */
    @Override
    public int deleteRoomBatch(List<Integer> id) {
        return this.roomMapper.deleteRoomBatch(id);
    }
}
